<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="${pageContext.request.contextPath}/static/bootstrap-3.3.5/css/bootstrap.css" rel="stylesheet">
    <style>
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
        .thead-info {
            color: #fff;
            font-weight: bold;
            background-color: #5bc0de;
        }
    </style>
</head>
<body>
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue">
            <td colspan="4">购买申请单详情</td>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td class="col-md-2"><label>申请单号</label></td>
            <td class="col-md-4">${main.docNo}</td>
            <td class="col-md-2"><label>审批流程</label></td>
            <td class="col-md-4">资产购买申请</td>
        </tr>
        <tr>
            <td><label>创建人</label></td>
            <td>${creatorName}</td>
            <td><label>单据类型</label></td>
            <td>购买申请单</td>
        </tr>
        <tr>
            <td><label>申请人</label></td>
            <td>${proposerName}</td>
            <td><label>申请时所在部门</label></td>
            <td>${deptName}</td>
        </tr>
        <tr>
            <td><label>创建时间</label></td>
            <td>
               ${main.createDate}
            </td>
            <td><label>提交时间</label></td>
            <td>
                ${main.submitDate}
            </td>
        </tr>
        <tr>
            <td><label>采购事由</label></td>
            <td>${main.reason}</td>
            <td><label>单据状态</label></td>
            <td>
                <c:choose>
                    <c:when test="${main.status == 'B'}">待报价</c:when>
                    <c:when test="${main.status == 'W'}">未提交</c:when>
                    <c:when test="${main.status == 'O'}">审批中</c:when>
                    <c:when test="${main.status == 'Y'}">审批通过可购买</c:when>
                    <c:when test="${main.status == 'N'}">审批不通过</c:when>
                    <c:otherwise>${main.status}</c:otherwise>
                </c:choose>
            </td>
        </tr>
        <tr>
            <td><label>备注</label></td>
            <td colspan="3">${main.remark}</td>
        </tr>

        <!-- 循环展示购买明细 -->
        <c:forEach items="${details}" var="detail" varStatus="detailStatus">
            <tr class="thead-blue">
                <td colspan="4">购买明细(${detailStatus.index + 1})</td>
            </tr>
            <tr>
                <td><label>资产名称</label></td>
                <td>${detail.assetName}</td>
                <td><label>序列号</label></td>
                <td>${detail.assetNumber}</td>
            </tr>
            <tr>
                <td><label>规格</label></td>
                <td>${detail.guige}</td>
                <td><label>购买数量</label></td>
                <td>${detail.quantity}</td>
            </tr>
            <tr>
                <td><label>单价</label></td>
                <td>${detail.unitPrice}</td>
                <td><label>采购时间</label></td>
                <td>
                    ${detail.purchaseDate}
                </td>
            </tr>

            <!-- 循环展示该明细的所有报价 -->
            <c:forEach items="${detail.baojiaList}" var="baojia" varStatus="baojiaStatus">
                <tr>
                    <td style="vertical-align: middle;">
                        <label>${detail.assetName}报价(${baojiaStatus.index + 1})</label>
                    </td>
                    <td colspan="3">
                        <table class="table table-bordered">
                            <tr>
                                <td class="col-md-2"><label>联系人</label></td>
                                <td class="col-md-4">${baojia.linkman}</td>
                                <td class="col-md-2"><label>联系人电话</label></td>
                                <td class="col-md-4">${baojia.linkPhone}</td>
                            </tr>
                            <tr>
                                <td><label>价格</label></td>
                                <td>${baojia.price}</td>
                                <td><label>备注</label></td>
                                <td>${baojia.remark}</td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </c:forEach>
        </c:forEach>

        <tr>
            <td colspan="4" align="center">
                <a type="button" href="javascript:history.back()" class="btn btn-info">返回</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<script src="${pageContext.request.contextPath}/static/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
    $(document).ajaxError(function(event,xhr) {
        if(xhr.status=="403"){//没有权限
            document.location.href = xhr.getResponseHeader("url");
        }else if(xhr.status!="200"){
            console.log("服务器错误!");
        }
    });
</script>
</body>
</html>